
#include <BFont>
#include <BWidget>
#include "member_BButtonGroup.h"
#include "member_BButton.h"

using namespace BWE;

member_BButtonGroup::member_BButtonGroup(BButtonGroup* buttonGroup)
{
	boss = buttonGroup;
	selectMode = Select_Single;
}
member_BButtonGroup::~member_BButtonGroup()
{

}

void member_BButtonGroup::slotButtonChecked(BObject* object, const BValue& value)
{
	BButton* button = (BButton*)object;
	if (selectMode == Select_Single)
	{
		if (button->checked())
		{
			for (int i = 0; i < buttons.size(); i++)
			{
				if (buttons[i] != button)
				{
					buttons[i]->setChecked(false);
					buttons[i]->fresh();
				}
			}
			checkedButtons.reset();
			checkedButtons.insert(button);
		}
		else
		{
			checkedButtons.remove(button);
		}
	}
	if (selectMode == Select_Multiple)
	{
		if (button->checked())
		{
			checkedButtons.insert(button);
		}
		else
		{
			checkedButtons.remove(button);
		}
	}
	boss->emit(Signal_Checked, button);
}
void member_BButtonGroup::slotButtonToggled(BObject* object, const BValue& value)
{
	BButton* button = (BButton*)object;
	boss->emit(Signal_Toggled, button);
}

